<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>

<div id="content"></div>

</body>
<head>
    <script type="text/javascript" src="http://ajax.microsoft.com/ajax/jquery
/jquery-1.4.min.js"></script>


    <script>
        $(document).ready(function(){
            var html='';

            $.ajax(
                {   contentType: "application/x-www-form-urlencoded;charset=UTF-8",
                    url:"/showUploadFiles",
                    type:"post",
                    dataType:"json",
                    success:function(res){
                       var html="";
                       var a="";
                       var datas=res.data;
                       var url=res.url;
                        var urlAddress;
                       for(var i=0;i<datas.length;i++){
                           var data=datas[i].file_path;
                           var lastIndex=data.lastIndexOf('.');
                           var filetype=data.substring(lastIndex+1,data.length);
                           if(filetype=="doc"||filetype=="docx"){
                               // data=data.substring(0,lastIndex);

                               urlAddress="/showDoc?filename="+encodeURI(encodeURI(data,"UTF-8"));
                           }else{
                               urlAddress=url+data;
                           }

                           a="<div><a href='"+urlAddress+"'>"+data+"</a><br/><br/></div>";

                           html+=a;

                       }
                        $("#content").html(html);


                        // for(var i=0;i<datas.length;i++) {
                        //     alert(datas[i].file_path);
                        // }

                    },
                    error:function(res){
                        alert(res);
                    }
                }

            );
        });
    </script>
</head>
</html>